<?php
namespace app\home\controller;
use think\Db;
use think\captcha\Captcha;
use think\Loader;
class Homepage extends \think\Controller{
    public function homepage(){
        $reslist=db('banner')->select();
        $this->assign('reslist',$reslist);
        $list=db('article')->select();
        $this->assign('list',$list);
        return $this->fetch('homepage');//继承基类的控制器 
    }
    public function contentList(){
        $pageno=input('get.pageno');
        $pagesize=1;
        $left=($pageno-1)*$pagesize;
        $content=db('article')->where('topic',3)->limit($left,$pagesize)->select();
        if(empty($content)){
            $this->error('没有数据了','','');
        }
       
        $data=array();
        foreach($content as $val){
            $img=json_decode($val['img'],true);
            if($img!=NULL){
                $val['img']=$img;
            }
            $data[]=$val;
        }
        $this->assign('content',$data);
        // return $this->fetch('indexlist');
        
        $html=$this->fetch('indexlist');
        $this->success('ok','',$html);
        // return  $content;
    }
}